<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link
	href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css"
	rel="stylesheet">
<link href="${pageContext.request.contextPath}/themes/icon.css"
	rel="stylesheet">
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
<title>查询过往用户</title>
</head>
<script type="text/javascript">
   $(function() {
		//配置搜索框
		$('#findoldusername').searchbox({
			searcher : function(value, name) {
				var oldusername = value;
				$('#oldusertable').datagrid('reload', {
					searchname : oldusername
				});
			}
		});
		//配置还原按钮点击事件
		$('#restoreuser').bind('click',function(){
			var allchecked = $('#oldusertable').datagrid('getChecked').length;
			if(allchecked == 0){
				alert("请至少选择一项进行还原");
			}
			else{
				var allcheckeds = $('#oldusertable').datagrid('getChecked');
				var allchecks = [] ;
				$.each(allcheckeds,function(index,i){
					allchecks.push(i.userid);
				})
					$.ajax({
						type:'post',
						url:'${pageContext.request.contextPath}/restoreuser',
						data:{'allchecks':allchecks},
						dataType:'json',
						success:function(data){
							if(data=="1"){
								$.messager.alert('我的消息','还原成功','info',function(){
									$('#oldusertable').datagrid('reload');
								});
								
							}
						}
					})
			}
		});
		//	配置取消按钮事件
		$('#close').bind('click',function(){
			$('#oldusertable').datagrid('uncheckAll');
		});
		//配置数据表格
		$('#oldusertable').datagrid({
			
			url : '${pageContext.request.contextPath}/findoldusers',
			columns : [ [{
				field:'ck',
				checkbox:true,
				ctrlSelect:true,

			},{
				field : 'userid',
				title : '用户编号',
				width : 100,
				hidden : true
			}, {
				field : 'username',
				title : '用户姓名',
				width : 100
			}, {
				field : 'userphone',
				title : '用户电话',
				width : 100,
				align : 'right'
			}, {
				field : 'useraddr',
				title : '用户地址',
				width : 100,
				align : 'right'
			},] ],
			pagination : true,
			striped : true,
			rownumbers : true,
		});
		
	});
</script>
<body>
	<div style="margin-bottom:30px;margin-top:20px;margin-left:20px">
	<input style="width:200px;height:30px" id="findoldusername" class="easyui-searchbox" data-options="prompt:'输入姓名查询信息',width:150">
	<a  id="restoreuser" style="margin-left:80px; height:30px"  class="easyui-linkbutton" data-options="iconCls:'icon-remove'">还原</a>
			<a id="close" style="margin-left:40px; height:30px" class="easyui-linkbutton" data-options="iconCls:'icon-reload'">取消</a>
</div>
	
	<table id="oldusertable" style="width:500px"></table>
</body>
</html>